<?
namespace xto\data\service;

use xto\data\model\ManagerModel; 
use xto\data\Factory;
use think\Db;

class MemberService{  
	static function getlist($pagezie){
		$result = Db::view('xto_members','*')
			->view('xto_users',['username','email','createdate','is_approved','last_login_date'],'xto_users.userid=xto_members.userid')
			->order('xto_users.createdate', 'desc')
			->paginate($pagezie);
		$b=array(
			'list'=>$result,
			'page'=>$result->render()
			);	 
		return $b;
	}

	static function getuser($userid){
		$result = Db::view('xto_members','*')
			->view('xto_users',['username','email','createdate','is_approved'],'xto_users.userid=xto_members.userid')
			->where('xto_users.userid', $userid)
			->select();  
		if(count($result)>0){
			return $result[0];
		}
		return null;
	}

	static function getroles($pagezie){
		$result = Db::view('xto_roles','roleid,name') 
			->order('roleid', 'desc')
			->paginate($pagezie);
		$b=array(
			'list'=>$result,
			'page'=>$result->render()
			);	 
		return $b;
	}
}